// pages/achivements/achivements.js
let app =  getApp();

Page({

    /**
     * Page initial data
     */
    data: {
        datas:[],//内含六张图片地址，就是那六个亮灭灯泡，在页面里直接调用即可
    },

    /**
     * Lifecycle function--Called when page load
     */
    onLoad: function (options) {
        var that = this;
        //获取成就数据
        wx.request({
            url: app.globalData.urlHome + '/ach/all',
            data: {
                "openid": wx.getStorageSync('openid'),
            },
            header: {'content-type':'application/json'},
            method: 'POST',
            success: (result) => {
                that.setData({
                    datas: result.data,
                })

                //为datas添加属性（图片地址）
                that.setData({
                    ['datas[' + 0 + '].achivementoff']: 'http://www.kynix.top:8080/fileManager-1.0-SNAPSHOT/image/sduhour/achivement/achivementoff.png',
                    ['datas[' + 0 + '].achivementon']: 'http://www.kynix.top:8080/fileManager-1.0-SNAPSHOT/image/sduhour/achivement/achivementon.png',
                    ['datas[' + 0 + '].dghsoff']: 'http://www.kynix.top:8080/fileManager-1.0-SNAPSHOT/image/sduhour/achivement/dghsoff.png',
                    ['datas[' + 0 + '].dghson']: 'http://www.kynix.top:8080/fileManager-1.0-SNAPSHOT/image/sduhour/achivement/dghson.png',
                    ['datas[' + 0 + '].fglyoff']: 'http://www.kynix.top:8080/fileManager-1.0-SNAPSHOT/image/sduhour/achivement/fglyoff.png',
                    ['datas[' + 0 + '].fglyon']: 'http://www.kynix.top:8080/fileManager-1.0-SNAPSHOT/image/sduhour/achivement/fglyon.png',
                })
            },
            fail: () => {},
            complete: () => {}
        });
          
    },

    /**
     * Lifecycle function--Called when page is initially rendered
     */
    onReady: function () {

    },

    /**
     * Lifecycle function--Called when page show
     */
    onShow: function () {

    },

    /**
     * Lifecycle function--Called when page hide
     */
    onHide: function () {

    },

    /**
     * Lifecycle function--Called when page unload
     */
    onUnload: function () {

    },

    /**
     * Page event handler function--Called when user drop down
     */
    onPullDownRefresh: function () {

    },

    /**
     * Called when page reach bottom
     */
    onReachBottom: function () {

    },

    /**
     * Called when user click on the top right corner to share
     */
    onShareAppMessage: function () {

    }
})